# Makefile for TPIE test applications.
# Use gmake on this Makefile.  It relies on the default rules, and 
# Use gmake -p to see the default rules.
# $Id: Makefile.in,v 1.42 2005/08/24 19:36:00 adanner Exp $

CXX = @CXX@
CC = @CC@
MAKEDEPEND = $(CXX) -M

TPIEINC = ../include
TPIELIBDIR = ../lib
TPIELIB = $(TPIELIBDIR)/libtpie.a
TPIEBINDIR = ../bin

ifdef DEBUG_APPS
LOG_APPS = 1
ASSERT_DEBUG_APPS = 1
endif

CXXFLAGS = 

# CPPFLAGS is used by the default rules. Using "override" and "+="
# allows the user to prepend things to CPPFLAGS on the command line.
override CPPFLAGS +=  -I$(TPIEINC)
# These options are set by the configure script.
override CPPFLAGS += @DEFS@
# These options are for large file support. They force all file access
# calls to use the 64 bit variants. Several types change also, e.g. off_t
# becomes off64_t.
override CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
#override CPPFLAGS += -DTPIE_SORT_SMALL_MRGARITY=2
#override CPPFLAGS += -DTPIE_SORT_SMALL_RUNSIZE=10000
#override CPPFLAGS += -DTPIE_USE_STL_SORT



ifeq ($(MINUSG),1)
override CPPFLAGS += -g
else
override CPPFLAGS += -O3
endif

ifeq ($(MINUSPG),1)
override CPPFLAGS += -pg
endif

LDLIBS =  -L$(TPIELIBDIR) -ltpie -lm #-liberty

CCFLAGS = $(CXXFLAGS)

# The various test applications.

APPS := test_ami_pmerge \
	test_ami_sort \
	test_ami_merge \
	test_ami_gp \
	test_ami_arith \
	test_ami_matrix	\
	test_ami_matrix_pad \
	test_ami_stack \
	test_ami_bp \
	test_ami_sm \
	test_ami_sort24	\
	test_ami_btree \
	test_correctness \
	test_big_scan \
	test_sort 
 


# Sources to the test applications.
APPSRC = $(patsubst %,%.cpp,$(APPS))

# Other C++ sources for common support routines.
COMMONCXXSRC = parse_args.cpp app_config.cpp getopts.cpp

COMMONCSRC = 

OTHERCXXSRC = scan_random.cpp \
	scan_count.cpp \
	scan_uniform_sm.cpp 

CXXSRC = $(APPSRC) $(COMMONCXXSRC) $(OTHERCXXSRC)

# Common objects that go into most apps.
COMMONOBJ = $(COMMONCXXSRC:.cpp=.o) $(COMMONCSRC:.c=.o)

# C sources.
CSRC = 

# Translation rules:

%:%.o
	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $(TPIEBINDIR)/$@


# Specific dependencies, explicit and automatic.

all: $(APPS)

depend: cleandepend 
	$(MAKEDEPEND) $(CPPFLAGS) $(CSRC) $(CXXSRC) >> Makefile.depend

clean: cleandepend
	-rm -f $(CSRC:.c=.o) $(CXXSRC:.cpp=.o)
	$(foreach APP,$(APPS), (rm -f $(TPIEBINDIR)/$(APP));)

distclean: clean


# What objects each of the apps acually needs.

test_ami_pmerge: test_ami_pmerge.o scan_random.o $(COMMONOBJ)
test_ami_sort: test_ami_sort.o scan_random.o $(COMMONOBJ)
test_ami_merge: test_ami_merge.o scan_count.o $(COMMONOBJ)
test_ami_gp: test_ami_gp.o scan_count.o $(COMMONOBJ)
test_ami_bp: test_ami_bp.o scan_count.o $(COMMONOBJ)
test_ami_arith: test_ami_arith.o scan_count.o $(COMMONOBJ)
test_ami_matrix_pad: test_ami_matrix_pad.o scan_count.o	$(COMMONOBJ)
test_ami_matrix: test_ami_matrix.o scan_count.o $(COMMONOBJ)
test_ami_stack: test_ami_stack.o $(COMMONOBJ)
test_ami_sm: test_ami_sm.o scan_uniform_sm.o $(COMMONOBJ)
test_ami_sort24: test_ami_sort24.o $(COMMONOBJ)
test_ami_btree: test_ami_btree.o
test_correctness: test_correctness.o getopts.o
test_big_scan: test_big_scan.o getopts.o
sample_pgm: sample_pgm.o getopts.o 
test_sort: test_sort.o getopts.o

include Makefile.depend

Makefile.depend: #$(CSRC) $(CXXSRC)
	rm -f Makefile.depend; \
	$(MAKEDEPEND) $(CPPFLAGS) $(CSRC) $(CXXSRC) >> Makefile.depend

cleandepend:
	-rm -f Makefile.depend

.PHONY : clean all depend cleandepend distclean


